package com.general.template.config;

import com.general.template.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Author: 杰哥
 * @Description:
 **/
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
//    @Bean
//    public LoginInterceptor loginInterceptor() {
//        return new LoginInterceptor();
//    }
//    /** @Author xu199
//     * @Description //TODO 添加自定义拦截器
//     * @Date 23:17 2020/12/1
//     * @Param [registry]
//     * @return void
//     **/

//    @Override
//    protected void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(loginInterceptor()).addPathPatterns("/**")
//                .excludePathPatterns("/*/login","/doc.html","/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
//        super.addInterceptors(registry);
//    }

    /** @Author xu199
     * @Description //TODO 添加静态资源文件
     * @Date 23:17 2020/12/1
     * @Param [registry]
     * @return void
     **/
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("**/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/swagger-resources/**").addResourceLocations("classpath:/META-INF/swagger-resources/");
        registry.addResourceHandler("/v2/**").addResourceLocations("classpath:/META-INF/resources/v2");
    }
}
